package com.haizhi.crm.api.controller.recommend;

import com.haizhi.crm.common.constant.CrmSchema;
import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.recommend.constant.RecType;
import com.haizhi.crm.recommend.engine.RecEngine;
import com.haizhi.crm.recommend.model.RecQo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yangyijun on 2018/7/5.
 */
@Api(description = "[动态|事件-推荐]" )
@RestController
@RequestMapping("/event" )
public class EventRecController {
    @Autowired
    private RecEngine recEngine;

    @ApiOperation(value = "行内动态推荐栏热搜" )
    @GetMapping(path = "/innerHotSearch" )
    public Response innerHotSearch() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.InnerEvent.SEARCH_HOT_SEARCH, null));
    }

    @ApiOperation(value = "行内动态推荐栏最近浏览" )
    @GetMapping(path = "/innerRecentView" )
    public Response innerRecentView() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.InnerEvent.SEARCH_RECENT_VIEW, null));
    }

    @ApiOperation(value = "行内动态推荐栏相关事件" )
    @GetMapping(path = "/innerRelation" )
    public Response innerRelation(@RequestParam String objectKey) {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.InnerEvent.SEARCH_RELATION_SEARCH, objectKey));
    }

    @ApiOperation(value = "行外事件推荐栏热搜" )
    @GetMapping(path = "/outerHotSearch" )
    public Response outerHotSearch() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.OuterEvent.SEARCH_HOT_SEARCH, null));
    }

    @ApiOperation(value = "行外事件推荐栏最近浏览" )
    @GetMapping(path = "/outerRecentView" )
    public Response outerRecentView() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.OuterEvent.SEARCH_RECENT_VIEW, null));
    }

    @ApiOperation(value = "行外事件推荐栏相关事件" )
    @GetMapping(path = "/outerRelation" )
    public Response outerRelation(@RequestParam String objectKey) {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.OuterEvent.SEARCH_RELATION_SEARCH, objectKey));
    }
}
